package com.scada.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.scada.hessian.client.impl.PermissionRoleVisitorClient;
import com.scada.model.bean.PermissionRole;
import com.scada.model.result.ResponseBean;
import com.scada.service.PermissionRoleService;


@Service
public class PermissionRoleServiceImpl implements PermissionRoleService{

	@Autowired
	private PermissionRoleVisitorClient permissionRoleVisitorClient;
	
	@Override
	public ResponseBean selectPermissionByRoleKey(Integer roleId) {
		
		return permissionRoleVisitorClient.selectPermissionByRoleKey(roleId);
	}

	@Override
	public ResponseBean savePermissionByRoleKey(Integer roleId, Integer[] ids) {
		List<PermissionRole> perList = new ArrayList<PermissionRole>();
		for(Integer id : ids){
			PermissionRole pr = new PermissionRole();
			pr.setRoleId(roleId);
			pr.setPermId(id);
			perList.add(pr);
		}
		return permissionRoleVisitorClient.savePermissionByRoleKey(roleId, perList);
	}
}
